package com.feinno.bug.actcache.service;

import com.feinno.bug.actcache.controller.SpringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: zcy
 * @Description
 * @Date: 18:18 2018/11/2
 */
public class MyRunner implements Runnable {

    private static final Logger logger = LoggerFactory.getLogger(MyRunner.class);

    private static RedisService redisService;

    static {
        redisService = SpringUtil.getBean(RedisService.class);
    }

    private String key;

    private String phone;

    private String group;

    private Integer index;

    public MyRunner() {
    }


    public MyRunner(String key, Integer index, String phone, String group) {
        this.key = key;
        this.index = index;
        this.phone = phone;
        this.group = group;
    }

    @Override
    public void run() {
        List<String> result = Arrays.asList(group.split(","));
//        redisService.del(key + phone);
        redisService.leftPushAll(key + phone, result);
//        redisService.setStringToRedis(result, key + phone);
        logger.info(" {} 号线程在执行用户 {} 的操作 {}---{}", Thread.currentThread().getName(), phone, key, index);
    }

}
